package worklog.dto;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.google.gson.Gson;

public class ProjectDTO {
	private int id;
	private String name; 
	private String tags;
	private Boolean isFav;
	private Boolean archive;
	private int entries;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTags() {
		return tags;
	}

	public void setTags(String tags) {
		if (tags != null && tags != "null") this.tags = tags;
		else this.tags = "";
	}
	
	public Boolean getIsFav() {
		return isFav;
	}
	
	public void setIsFav(Boolean isFav) {
		this.isFav = isFav;
	}
	
	public Boolean getArchive() {
		return archive;
	}

	public void setArchive(Boolean archive) {
		this.archive = archive;
	}

	public int getEntries() {
		return entries;
	}

	public void setEntries(int entries) {
		this.entries = entries;
	}

	public void set(ResultSet res) {
		try { setId(res.getInt("id")); } catch (SQLException e) { }
		try { setName(res.getString("name")); } catch (SQLException e) { }
		try { setEntries(res.getInt("entries")); } catch (SQLException e) { }
		try { setTags(res.getString("tags")); } catch (SQLException e) { }
		try { setIsFav(res.getBoolean("isFav")); } catch (SQLException e) { }
		try { setArchive(res.getBoolean("archive")); } catch (SQLException e) { }
	}

	public String toString() {
		return new Gson().toJson(this);		
	}

}
